// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_delete_ok.java

package logistics.product_providers;

import include.nseer_cookie.exchange;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataTag;

public class check_delete_ok extends HttpServlet
{

	public check_delete_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			nseer_db_backup1 logistics_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 logistics_db1 = new nseer_db_backup1(dbApplication);
			if (logistics_db.conn((String)dbSession.getAttribute("unit_db_name")) && logistics_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				ValidataTag vt = new ValidataTag();
				String product_logistics_recommend_ID = request.getParameter("product_logistics_recommend_ID");
				String recommender = request.getParameter("recommender");
				String bodyc = new String(request.getParameter("recommend_describe").getBytes("UTF-8"), "UTF-8");
				String recommend_describe = exchange.toHtml(bodyc);
				String check_time = request.getParameter("check_time");
				String checker = request.getParameter("checker");
				String checker_ID = request.getParameter("checker_ID");
				String product_ID = request.getParameter("product_ID");
				String config_id = request.getParameter("config_id");
				String choice = request.getParameter("choice");
				String product_name = request.getParameter("product_name");
				String sql6 = (new StringBuilder("select id from logistics_workflow where object_ID='")).append(product_logistics_recommend_ID).append("' and ((check_tag='0' and config_id<'").append(config_id).append("') or (check_tag='1' and config_id='").append(config_id).append("'))").toString();
				ResultSet rs6 = logistics_db.executeQuery(sql6);
				if (!rs6.next())
				{
					if (vt.validata((String)dbSession.getAttribute("unit_db_name"), "logistics_product_providers_recommend", "product_logistics_recommend_ID", product_logistics_recommend_ID, "check_tag").equals("0"))
						try
						{
							String sql2 = (new StringBuilder("update logistics_product_providers_recommend set check_time='")).append(check_time).append("',checker='").append(checker).append("',recommender='").append(recommender).append("',recommend_describe='").append(recommend_describe).append("',change_tag='0' where product_logistics_recommend_ID='").append(product_logistics_recommend_ID).append("'").toString();
							logistics_db.executeUpdate(sql2);
							String sql1 = (new StringBuilder("update design_file set recommend_provider_tag='0' where product_ID='")).append(product_ID).append("'").toString();
							logistics_db1.executeUpdate(sql1);
							if (choice != null)
							{
								if (choice.equals(""))
								{
									String sql = (new StringBuilder("update logistics_product_providers_recommend set check_tag='9' where product_logistics_recommend_ID='")).append(product_logistics_recommend_ID).append("'").toString();
									logistics_db.executeUpdate(sql);
									sql = (new StringBuilder("delete from logistics_workflow where object_ID='")).append(product_logistics_recommend_ID).append("'").toString();
									logistics_db.executeUpdate(sql);
								} else
								{
									sql6 = (new StringBuilder("select id from logistics_workflow where object_ID='")).append(product_logistics_recommend_ID).append("' and config_id<'").append(config_id).append("' and config_id>='").append(choice).append("'").toString();
									String sql;
									for (rs6 = logistics_db.executeQuery(sql6); rs6.next(); logistics_db1.executeUpdate(sql))
										sql = (new StringBuilder("update logistics_workflow set check_tag='0' where id='")).append(rs6.getString("id")).append("'").toString();

								}
								response.sendRedirect("logistics/product_providers/check_delete_ok.jsp?finished_tag=3");
							} else
							{
								response.sendRedirect("logistics/product_providers/check_delete_ok.jsp?finished_tag=2");
							}
						}
						catch (Exception ex)
						{
							ex.printStackTrace();
						}
					else
						response.sendRedirect("logistics/product_providers/check_delete_ok.jsp?finished_tag=0");
				} else
				{
					response.sendRedirect("logistics/product_providers/check_delete_ok.jsp?finished_tag=1");
				}
				logistics_db.commit();
				logistics_db1.commit();
				logistics_db.close();
				logistics_db1.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
